package cn.edu.bjtu.toychange.dao.support;

import org.hibernate.Session;

import cn.edu.bjtu.toychange.dao.BaseDao;

public class SearchCondition extends BaseDao{
	private String keyword;
	private String type;
	private double lowNewoldDegree;
	private double highNewoldDegree;
	private double lowPrice;
	private double highPrice;
	private int lowAge;
	private int highAge;
	private Session session;
	
	public SearchCondition() {
		session = getSession();
		
		session.beginTransaction();
		keyword = null;
		type = null;
		lowNewoldDegree = (double) session.createQuery("Select MIN(T_newoldDegree) FROM toy").uniqueResult();
		highNewoldDegree = (double) session.createQuery("Select MAX(T_newoldDegree) FROM toy").uniqueResult();
		lowPrice = (double) session.createQuery("Select MIN(T_intialPrice) FROM toy").uniqueResult();
		highPrice = (double) session.createQuery("Select MAX(T_intialPrice) FROM toy").uniqueResult();
		lowAge = (int) session.createQuery("Select MIN(T_lowAge) FROM toy").uniqueResult();
		highAge = (int) session.createQuery("Select MAX(T_highAge) FROM toy").uniqueResult();
		session.close();
	}
	
	public String getKeyword() {
		return keyword;
	}
	
	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}
	
	public int getLowAge() {
		return lowAge;
	}
	
	public void setLowAge(int lowAge) {
		this.lowAge = lowAge;
	}
	
	public int getHighAge() {
		return highAge;
	}
	
	public void setHighAge(int highAge) {
		this.highAge = highAge;
	}

	public double getLowNewoldDegree() {
		return lowNewoldDegree;
	}

	public void setLowNewoldDegree(double lowNewoldDegree) {
		this.lowNewoldDegree = lowNewoldDegree;
	}

	public double getHighNewoldDegree() {
		return highNewoldDegree;
	}

	public void setHighNewoldDegree(double highNewoldDegree) {
		this.highNewoldDegree = highNewoldDegree;
	}

	public double getLowPrice() {
		return lowPrice;
	}

	public void setLowPrice(double lowPrice) {
		this.lowPrice = lowPrice;
	}

	public double getHighPrice() {
		return highPrice;
	}

	public void setHighPrice(double highPrice) {
		this.highPrice = highPrice;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
}
